<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>用户登录</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" href="/static/index/amazeui/css/amazeui.min.css"/>
<link rel="stylesheet" href="/static/index/default/style.css"/>
<script src="/static/index/amazeui/js/jquery.min.js"></script>
<script src="/static/index/amazeui/js/amazeui.min.js"></script>
<link href="/static/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="/static/css/animate.css" rel="stylesheet">
</head>

<body>
<div class="container">
	<header data-am-widget="header" class="am-header am-header-default my-header">
      <div class="am-header-left am-header-nav">
        <a href="javascript:window.history.back();" class="">
          <i class="am-header-icon am-icon-chevron-left"></i>
        </a>
      </div>
      <h1 class="am-header-title">
        <a href="#title-link" class="">用户登录</a>
      </h1>
      <div class="am-header-right am-header-nav">
        <a href="reg.html" class="">
          	立即注册
        </a>
      </div>
    </header>
    <div class="cart-panel">
		<form class="am-form" id="loginForm" data-am-validator>
            <div class="am-form-group am-form-icon">
                <i class="am-icon-user" style="color:#329cd9"></i>
                <input type="text" name="username" class="am-form-field  my-radius" minlength="3" maxlength="20" placeholder="输入用户名" required="">
            </div>
            <div class="am-form-group am-form-icon">
                <i class="am-icon-lock" style="color:#329cd9"></i>
                <input type="password" name="password" value="123456" class="am-form-field  my-radius" 
                	minlength="6" maxlength="16" placeholder="请输入密码" required="" >
            </div>
            <div class="am-checkbox">
              <label>
                <input type="checkbox"> 记住密码
              </label>
            </div>
            <p class="am-text-center"><button type="button" class="am-btn am-btn-danger am-radius am-btn-block">立即登录</button></p>
        </form>
    </div>
    
    <footer data-am-widget="footer" class="am-footer am-footer-default" data-am-footer="{  }">
        <hr data-am-widget="divider" style="" class="am-divider am-divider-default"/>
      <div class="am-footer-miscs ">
        <p>CopyRight©2014 AllMobilize Inc.</p>
        <p>京ICP备13033158</p>
      </div>
    </footer>
</div>
<script src="/static/js/plugins/layer/layer.min.js"></script>
<!--<script src="/static/index/js/layer/mobile/layer.js"></script>-->
<script>
	$("button[type='button']").click(function(){
		if($("input[name='username']").val() != "" && $("input[name='password']").val() != ""){
			$.ajax({
	            url: "/index/index/loginPost",
	            data:  $("#loginForm").serialize(),
	            type: "POST",
	            dataType: 'json',
	            success: function(data){
	            	console.log(data)
	               if (data.success) {
	                    parent.layer.msg(data.msg, {icon: 6});
	                    window.location.href = "/index/index.html";
	                } else {
	                    parent.layer.msg(data.msg, {icon:5});
	                }
	            }
	        });
		}
		
		if($("input[name='password']").val() == ""  || $("input[name='password']").val().length < 6){
			parent.layer.msg($("input[name='password']").attr("placeholder"), {icon: 6});
		}
		if($("input[name='username']").val() == ""  || $("input[name='username']").val().length < 3){
			parent.layer.msg($("input[name='username']").attr("placeholder"), {icon: 6});
		}
	})
</script>
</body>
</html>
